#-----------------------------#
# pyLotLib
#-----------------------------#

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

#-----------------------------#

PROJECT(pyLotLib)
SET(CMAKE_MODULE_PATH ${pyLotLib_SOURCE_DIR}/install/cmake/Modules)

# Define global options
OPTION(PACKAGING "Update options for packaging" OFF)

IF("${pyLotLib_SOURCE_DIR}"  STREQUAL "${pyLotLib_BINARY_DIR}")
  MESSAGE(FATAL_ERROR "pyLot cannot be built in source directory. Please create a separate binary directory and run CMake there.")
ENDIF("${pyLotLib_SOURCE_DIR}"  STREQUAL "${pyLotLib_BINARY_DIR}")

IF("${pyLotLib_SOURCE_DIR}"  STREQUAL "${CMAKE_INSTALL_PREFIX}")
  MESSAGE(FATAL_ERROR "pyLot cannot be installed in source directory")
ENDIF("${pyLotLib_SOURCE_DIR}"  STREQUAL "${CMAKE_INSTALL_PREFIX}")

# Re-define variables if necessary (solve dependencies)
IF(CPACK_GENERATOR)
  SET(PACKAGING ON CACHE BOOL "" FORCE)
ENDIF(CPACK_GENERATOR)

IF(PACKAGING)
  MESSAGE(STATUS "---- Packaging mode ----")
  SET(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
  SET(SYSTEM_INSTALL ON CACHE BOOL "" FORCE)
  SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "" FORCE)
  SET(USERPATH_PROJECTS "~/pyLotProjects" CACHE PATH "" FORCE)
ENDIF(PACKAGING)

INCLUDE(PylotTree) #Installation path definition
INCLUDE(PylotUtils)
INCLUDE(FindPylot)

INCLUDE(FindPythonInterp)
ADD_SUBDIRECTORY(install)
ADD_SUBDIRECTORY(pyLot)

IF (PACKAGING)
  INCLUDE(PylotCPack)
ENDIF(PACKAGING)

OPTION(MAKE_TESTS "Build pyLot for tests" OFF)
IF(MAKE_TESTS)
  ENABLE_TESTING()
  ADD_SUBDIRECTORY("PylotTests")
ENDIF(MAKE_TESTS)

INSTALL(DIRECTORY plugins DESTINATION ${PYLOTPATH_EXTENSIONS})

INCLUDE(PylotSummary)
